package states.gameplay.shapors;

import org.newdawn.slick.Graphics;

public abstract class Shapor {
	
	public static enum State { BUILDING, DEPLOYED };
	
	private int _deployLimits;
	private int _cost;
	private int _energyUpkeep;
	private int _energyGenerated;
	private int _deployPulses;
	
	private State _currentState;
	
	public Shapor(int deployLimits, int cost, int deployPulses, int energyGenerated, int energyUpkeep){
		setDeployLimits(deployLimits);
		
		_cost = cost;
		
		setDeployPulses(deployPulses);
		
		setEnergyGenerated(energyGenerated);
		
		setEnergyUpkeep(energyUpkeep);
		
		_currentState = getDeployPulses() == 0 ? State.DEPLOYED : State.BUILDING;
	}
	
	public int getCost(){
		return _cost;
	}

	public int getDeployLimits(){
		return _deployLimits;
	}
	
	public void setDeployLimits(int deployLimits){
		
		if(deployLimits <= 0){
			throw new IllegalArgumentException("Deploy limits cannot be below or equal to zero");
		}
		
		_deployLimits = deployLimits;
	}
	
	public abstract void render(Graphics g, int x, int y);

	public State getCurrentState() {
		return _currentState;
	}

	public void setCurrentState(State currentState) {
		this._currentState = currentState;
	}

	public int getDeployPulses() {
		return _deployPulses;
	}

	private void setDeployPulses(int _deployPulses) {
		this._deployPulses = _deployPulses;
	}
	
	public void decreaseDeployPulses(){
		this._deployPulses -= 1;
		
		if(_deployPulses <= 0){
			setCurrentState(State.DEPLOYED);
		}
	}

	public int getEnergyGenerated() {
		return _energyGenerated;
	}

	public void setEnergyGenerated(int energyGenerated) {
		this._energyGenerated = energyGenerated;
	}

	public int getEnergyUpkeep() {
		return _energyUpkeep;
	}

	public void setEnergyUpkeep(int _energyComsuption) {
		this._energyUpkeep = _energyComsuption;
	}
}
